home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
F1 Licenseware
/
F1 Licenseware - Volume 1.iso
/
disks
/
003.dms
/
003.adf
/
TEXT
/
chapter20.txt
< prev
next >
Wrap
Text File
|
1992-09-02
|
8KB
|
309 lines
The Absolute Beginners Guide To Amos
-------------------------------------
Chapter Twenty
--------------
We are now going to take a look at a few more mouse commands and take our
first look at the joystick commands offered by Amos.
LIMIT MOUSE x1,y1 TO x2,y2
--------------------------
This command LIMITs the MOUSE pointer to any area of the screen, this can be
useful, if for example, you have a control panel on screen. As you would
expect x1,y1 are the coordinates for the top left hand corner of the box
and x2,y2 is the bottom right hand corner of the box area to be LIMITed.
The coordinates for this command must be in hardware coordinates these are
different to screen coordinates. Here is an alternative way to LIMIT the
MOUSE using the normal screen coordinates:
LIMIT MOUSE XHARD(X1),YHARD(Y1) TO XHARD(X2),YHARD(Y2)
-----------------------------------------------------
What we are doing is asking Amos to convert the screen coordinates into
hardware coordinates for us, a lot easier.
The LIMIT MOUSE command used on it`s own will restore the mouse pointer to
it`s original full screen limit.
X MOUSE
-------
Y MOUSE
-------
Returns the value of the X or Y mouse positions in hardware coordinates.
See EXAMPLE20.Amos for an ample demonstration of these commands.
------------------------------------
OK now a look at the joystick commands:
FIRE (port number)
------------------
This command tests if the FIRE button has been pressed.
FIRE must be followed by the port number to be tested in brackets:
X=FIRE(1)
The port on the right hand side of your Amiga (mouse port) is port 0 and the
normal joystick port (left side) is port 1.
The value returned in X will be -1 (minus one) if the fire button has been
pressed otherwise it will be 0, so a typical line in a game could be:
IF FIRE(1) then SHOOT
We do not need the -1 in the above line as -1 stands for true and the THEN
part of the statement will only be executed if the IF part is true,
if the IF part was false (0) then the THEN part will be ignored.
remember the (1) is the port number.
The rest of these joystick commands work exactly the same:
X=JLEFT (port number)
X=JRIGHT (port number)
X=JUP (port number)
X=JDOWN (port number)
-----------------------------------
The following are the latest commands we have looked at and a brief
description of each.
BAR Draw a filled rectangle
BOX Draw a hollow rectangle
CIRCLE Draw a circle
CHIP FREE Returns amount of free Chip memory left
DFREE Returns available bytes left on current disk
DIR$ Change current directory
DIM Dimension an array
DRAW Draw a straight line
END PROC This must be the last instruction of every procedure
EXIST Enquire if a file or disk exists
FAST FREE Returns amount of FAST memory available for use
FIRE Test if the joystick FIRE button has been pressed
FREE Returns available space left in variable buffer
GLOBAL Sets defined variables to be used inside and outside of procs
JDOWN Test for joystick down
JLEFT Test for joystick left
JRIGHT Test for joystick right
JUP Test for joystick up
KILL Delete a file permanently
LDIR Lists a directory of the current disk to the printer
LIMIT MOUSE LIMIT the MOUSE pointer to a defined rectangle of the screen
LLIST *Lists a basic program to the printer
LPRINT Print a string of text to the printer
MKDIR Create a folder or drawer on the current disk
PLOT Plot a pixel of colour onto the screen
PROCEDURE Create a procedure
POP PROC Abort a procedure before it`s natural end
READ Used to read data statements, usually for DIMensioned arrays
RENAME Rename a file
SORT Sort a dimensioned array in alpha or numerical order
XGR Returns the X value of graphics cursors current position
XHARD Converts screen to hardware coordinates
XMOUSE Returns the X value of the mouse pointer in hardware coords
YGR Returns the Y value of graphics cursors current position
YHARD Converts screen coordinates to hardware coordinates
YMOUSE Returns the Y value of the mouse pointer in hardware coords
*LList does not work on the original Amos package, if you want to print your
program listing to the printer select it as a block and use PRINT BLOCK from
the menus at the top of the screen.
----------------------------------------------------------------------------
And here is the very last of the Self TEST Quizzes.
===================================================
Q 1. What does the command BAR achieve?
a) Draws a filled rectangle
b) Draws a hollow rectangle
c) Draws a triangle
Q 2. Which command would you use to delete a file from a disk?
a) Delete
b) DIR$
c) Kill
Q 3. Who is the odd man out?
a) DIM
b) Read
c) Plot
Q 4. What would the following line achieve?
MKDIR "DF0: KILL"
a) Creates a drawer on DF0:
b) Deletes all the files on DF0:
c) Installs the disk in DF0:
Q 5. How would you break out of a procedure before the END PROC command?
a) GOSUB
b) GOTO
c) POP PROC
Q 6. What does the last parameter (c) in PLOT x,y,c stand for?
a) Clear
b) Colour
c) Cls
Q 7. What do the XGR and YGR commands achieve?
a) Return the graphics cursors current coordinates
b) Return the text cursors current coordinates
c) return the disk drives warp speed
Q 8. What is wrong with the following?
DRAW 100,10
a) There are two parameters missing
b) The syntax is correct
c) There is one parameter missing.
Q 9. Who is the odd man out?
a) PROCEDURE
b) POP PROC
c) EXIST
Q10. What does the SORT command achieve?
a) Sorts a dimensioned array into order
b) Sorts memory chunks into slices
c) Sorts out your personal life
-----------------------------------
This seems as good a time as any to have a quick look at key press commands.
We are familiar with WAIT KEY and CLEAR KEY but what if we want to know the
exact key that was pressed by the user, from a menu of options maybe.
The following short piece of code I have used many many times in my basic
programs over the years, make a note as I am sure you will use it too.
CLEAR KEY: K$="": WHILE K$="": K$=INKEY$: WEND
This line will CLEAR the KEYboard buffer of any previous key presses and
start looping between WHILE and WEND until a key is pressed, when this
happens the loop will be broken and K$ will contain the key that was pressed.
Your next lines could read something like this:
IF K$="1" THEN DOSOMETHING
IF K$="Q" THEN QUITGAME
etc.
There are lots of different ways of achieving the same result but I prefer
this as it`s simple and effective.
-----------------------------------------
Well that is the end of this Absolute beginners tutorial. By now you should
have the grasp of quite a few of Amos`s commands, there are many more
commands and techniques to discover, I have barely scratched the surface.
I have tried to keep it as simple as possible and as a result not all of the
uses of commands have been covered this is, in my opinion, the best way to
learn as confusion over a certain command makes most people shy away from it
for good, where as a small understanding of that command may lead to the
person confidently making further investigations themselves.
I hope you have enjoyed this tutorial and have profited from it, weather I
write Vol 2 of this guide will depend on how popular it is and if I can get
the time together.
Load up the Amos programs in the EXTRAS drawer on this disk. There are some
excellent programs in there that you can learn a lot from. Hope you enjoy
them.
Before I go here are the answers to the self testing quiz:
1.A 6. B
2.C 7. A
3.C 8. A
4.A 9. C
5.C 10. A
Be seeing you!
End of tutorial.